//
//  Base.h
//  AudiHistory
//
//  Created by niko on 11-8-20.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

#define RELEASE_OBJECT(_OBJ_) { if(_OBJ_ != nil){ [_OBJ_ release]; _OBJ_ = nil; } }
#define RELEASE(_OBJ_) { if(_OBJ_ != NULL){ delete _OBJ_; _OBJ_ = NULL; } }

CG_INLINE NSString* fullPathFromRelativePath(NSString* relPath)
{	
	NSString *fullpath = nil;
	
	// only if it is not an absolute path
	if( ! [relPath isAbsolutePath] )
	{
		NSString *file = [relPath lastPathComponent];
		NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
		
		fullpath = [[NSBundle mainBundle] pathForResource:file
												   ofType:nil
											  inDirectory:imageDirectory];
	}
	
	if (fullpath == nil)
		fullpath = relPath;
		
	return fullpath;
}
